#include "cvxSIFT.h"
#include "cvxImgfeatures.h"
#include "utils.h"

#include <stdio.h>

/******************************** Globals ************************************/

char* img_file_name = "beaver.png";//0147.jpg  0148.jpg  beaver.png
char* out_file_name  = "beaver.sift";;
char* out_img_name = NULL;
int display = 1;
int intvls = CVX_SIFT_INTVLS;
double sigma = CVX_SIFT_SIGMA;
double contr_thr = CVX_SIFT_CONTR_THR;
int curv_thr = CVX_SIFT_CURV_THR;
int img_dbl = CVX_SIFT_IMG_DBL;
int descr_width = CVX_SIFT_DESCR_WIDTH;
int descr_hist_bins = CVX_SIFT_DESCR_HIST_BINS;


/********************************** Main *************************************/
#if 0
int main( int argc, char** argv )
{
	IplImage* img, *img2;
	struct feature* features;
	CvxFeature *cvxfeatures;
	int n = 0, n2 = 0;

	fprintf( stderr, "Finding SIFT features...\n" );
	img = cvLoadImage( img_file_name, 1 );
	if( ! img )
	{
		fprintf( stderr, "unable to load image from %s", img_file_name );
		exit( 1 );
	}
	img2 = cvCloneImage(img);
	n = _sift_features( img, &features, intvls, sigma, contr_thr, curv_thr,
		img_dbl, descr_width, descr_hist_bins );
	fprintf( stderr, "Found %d features.\n", n );

	
	n2 = CvxSift::siftFeatures(img2, &cvxfeatures);
	CvxSift::drawFeatures(img2, cvxfeatures, n2);
	cvShowImage("CvxSift", img2);
	CvxSift::exportFeatures("cvxsift.sift", cvxfeatures, n2);

	if( display )
	{
		draw_features( img, features, n );
		cvNamedWindow( img_file_name, 1 );
		cvShowImage( img_file_name, img );	
	}

	if( out_file_name != NULL )
		export_features( out_file_name, features, n );

	if( out_img_name != NULL )
		cvSaveImage( out_img_name, img, NULL );

	cvWaitKey( 0 );
	return 0;
}
#endif